import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ArticleCategoryVO, ArticleCategoryForm, ArticleCategoryQuery } from '@/api/cms/articleCategory/types';

/**
 * 查询CMS文章分类列表
 * @param query
 * @returns {*}
 */

export const listArticleCategory = (query?: ArticleCategoryQuery): AxiosPromise<ArticleCategoryVO[]> => {
  return request({
    url: '/cms/articleCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询CMS文章分类详细
 * @param id
 */
export const getArticleCategory = (id: string | number): AxiosPromise<ArticleCategoryVO> => {
  return request({
    url: '/cms/articleCategory/' + id,
    method: 'get'
  });
};

/**
 * 新增CMS文章分类
 * @param data
 */
export const addArticleCategory = (data: ArticleCategoryForm) => {
  return request({
    url: '/cms/articleCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改CMS文章分类
 * @param data
 */
export const updateArticleCategory = (data: ArticleCategoryForm) => {
  return request({
    url: '/cms/articleCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除CMS文章分类
 * @param id
 */
export const delArticleCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cms/articleCategory/' + id,
    method: 'delete'
  });
};
